﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities;
using DAL;
using Utility;

namespace BUS
{
    public class Tbl_DoanhNghiep_BUS
    {
        public static Tbl_DoanhNghiep_Collection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            Tbl_DoanhNghiep_DAL dnDAL = new Tbl_DoanhNghiep_DAL();
            return dnDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static Tbl_DoanhNghiep_Collection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            Tbl_DoanhNghiep_DAL dnDAL = new Tbl_DoanhNghiep_DAL();
            return dnDAL.Get(cri.Criter, 0, 0, Tbl_DoanhNghiep_Columns.STT.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static Tbl_DoanhNghiep_Entities GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, Tbl_DoanhNghiep_Columns.STT.ToString(), Condition.EQUAL, iD);
            Tbl_DoanhNghiep_DAL dnDAL = new Tbl_DoanhNghiep_DAL();
            Tbl_DoanhNghiep_Collection dnCollection = dnDAL.Get(cri.Criter, 0, 0, Tbl_DoanhNghiep_Columns.STT.ToString(), OrderDirection.ASC.ToString(), out total);
            if (dnCollection.Count > 0)
                return dnCollection[0];
            return null;
        }
        public static Tbl_DoanhNghiep_Entities GetLast()
        {
            int total = 0;
            Criteria cri = new Criteria();
            Tbl_DoanhNghiep_DAL dnDAL = new Tbl_DoanhNghiep_DAL();
            Tbl_DoanhNghiep_Collection dnCollection = dnDAL.Get(cri.Criter, 0, 0, Tbl_DoanhNghiep_Columns.STT.ToString(), OrderDirection.DESC.ToString(), out total);
            if (dnCollection.Count > 0)
                return dnCollection[0];
            return null;
        }
        public static Tbl_DoanhNghiep_Entities GetByName(string iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, Tbl_DoanhNghiep_Columns.TaiKhoan.ToString(), Condition.LIKE, iD);
            Tbl_DoanhNghiep_DAL dnDAL = new Tbl_DoanhNghiep_DAL();
            Tbl_DoanhNghiep_Collection dnCollection = dnDAL.Get(cri.Criter, 0, 0, Tbl_DoanhNghiep_Columns.STT.ToString(), OrderDirection.ASC.ToString(), out total);
            if (dnCollection.Count > 0)
                return dnCollection[0];
            return null;
        }
        public static int TestUsername(string iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, Tbl_DoanhNghiep_Columns.TaiKhoan.ToString(), Condition.LIKE, iD);
            Tbl_DoanhNghiep_DAL dnDAL = new Tbl_DoanhNghiep_DAL();
            Tbl_DoanhNghiep_Collection dnCollection = dnDAL.Get(cri.Criter, 0, 0, Tbl_DoanhNghiep_Columns.STT.ToString(), OrderDirection.ASC.ToString(), out total);
            if (dnCollection.Count > 0)
                return dnCollection.Count;
            return 0;
        }
        public static int Insert(Tbl_DoanhNghiep_Entities dn)
        {
            Tbl_DoanhNghiep_DAL dnDAL = new Tbl_DoanhNghiep_DAL();
            return dnDAL.Insert(dn);
        }
        public static void Update(Tbl_DoanhNghiep_Entities dn)
        {
            Tbl_DoanhNghiep_DAL dnDAL = new Tbl_DoanhNghiep_DAL();
            dnDAL.Update(dn);
        }
        public static void Update_MK(Tbl_DoanhNghiep_Entities dn)
        {
            Tbl_DoanhNghiep_DAL dnDAL = new Tbl_DoanhNghiep_DAL();
            dnDAL.Update_MK(dn);
        }
        public static void Update_SODU(Tbl_DoanhNghiep_Entities dn)
        {
            Tbl_DoanhNghiep_DAL dnDAL = new Tbl_DoanhNghiep_DAL();
            dnDAL.Update_SODU(dn);
        }
        public static void Delete(int id)
        {
            Tbl_DoanhNghiep_DAL dnDAL = new Tbl_DoanhNghiep_DAL();
            dnDAL.Delete(id);
        }
    }
}
